package com.wky.basic.Result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult {
    private Integer code = 200;
    private String message = "操作成功";
    private Object data;

    //成功的静态方法(有数据)
    public static JsonResult success(Object data) {
        return new JsonResult(200,"success",data);
    }

    //成功的静态方法(没有数据)
    public static JsonResult success() {
        return new JsonResult(200,"success",null);
    }

    //成功的静态方法(没有数据)
//    public static JsonResult success(String msg) {
//        return new JsonResult(200,msg,null);
//    }

    //失败的静态方法(没有数据)
    public static JsonResult error() {
        return new JsonResult(0,"error",null);
    }

    public static JsonResult error(String msg) {
        return new JsonResult(0,msg,null);
    }
}
